/***************************************************************************
 *   Copyright (C) 2009 by Geoffrey McRae   *
 *   geoff@spacevs.com   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#include "mediaplayer.h"
#include "common/player.h"
#include <math.h>

inline void mp_add_time(struct timespec *ts, const unsigned long nsec) {
	uint64_t t  = ((uint64_t)ts->tv_sec * 1000000000L) + ts->tv_nsec + nsec;
	ts->tv_sec  = floor(t / 1000000000L);
	ts->tv_nsec = t - ((uint64_t)ts->tv_sec * 1000000000L);
}

inline void mp_double_to_ts(const double time, struct timespec *ts) {
	uint64_t t  = time * (double)1000000000L;
	ts->tv_sec  = floor(t / 1000000000L);
	ts->tv_nsec = t - ((uint64_t)ts->tv_sec * 1000000000L);
}

